# 多态: 前提是继承


class Animal(object):
    """动物类，定义了动物的基本行为和属性。"""
    def shout(self):
        print("Animal is making a sound.")


class Cat(Animal):
    """猫类，继承自Animal类，重写了shout方法。"""
    def shout(self):
        print("Meow!")

class Dog(Animal):
    """狗类，继承自Animal类，重写了shout方法。"""
    def shout(self):
        print("Woof!")

cat = Cat()
dog = Dog()
animal = Animal()

def animal_sound(animal):
    animal.shout()

animal_sound(animal)
animal_sound(dog)
animal_sound(cat)
